package xiaohongshu;

import java.util.Scanner;

public class Main3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for(int i=0;i<n;i++) arr[i] = in.nextInt();
        int caozuo = in.nextInt();
        int[][] mat = new int[2][caozuo];
        for(int i=0;i<2;i++){
            for(int j = 0;j<caozuo;j++){
                mat[i][j] = in.nextInt();
            }
        }
        in.nextLine();
        String s = in.nextLine();
        //操作数
        int[] num = new int[caozuo];
        for(int i=0;i<caozuo;i++){
            num[i] = in.nextInt();
        }

        for(int i=0;i<caozuo;i++){
            //第i次操作
            char c = s.charAt(i);
            int l = mat[0][i]-1;
            int r = mat[1][i]-1;
            switch (c){
                case '=':
                    for(int j = l;j<=r;j++){
                        arr[j] = num[i];
                    }
                    break;
                case '|':
                    for(int j = l;j<=r;j++){
                        arr[j] = arr[j]|num[i];
                    }
                    break;
                case '&':
                    for(int j = l;j<=r;j++){
                        arr[j] = arr[j]&num[i];
                    }
                    break;
            }
        }

        for(int x:arr){
            System.out.print(x+" ");
        }
    }
}
